Change in openvpn[master]: Remove last uses of inet_ntoa
A message that is not in the archive (sent off-list or not yet received): gerrit.1692709613000.I052bebe720ddf26340827f25b94705945e470bfa@...2715...
flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email )
Change subject: Remove last uses of inet_ntoa
......................................................................
Remove last uses of inet_ntoa
inet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that.
---
M src/openvpn/manage.c
M src/openvpn/route.c
M src/openvpn/socket.c
3 files changed, 17 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/326/1
src/openvpn/manage.c +3 -1
@@ -3058,9 +3058,11 @@/* listen on our local TUN/TAP IP address */ struct in_addr ia;int ret; +char buf[INET_ADDRSTRLEN ]; ia.s_addr =htonl (tun_local_ip); - ret =openvpn_getaddrinfo (GETADDR_PASSIVE ,inet_ntoa (ia),NULL ,0 ,NULL , +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (GETADDR_PASSIVE , buf,NULL ,0 ,NULL ,AF_INET , &man->settings.local);ASSERT (ret==0 );man_connection_init (man);
src/openvpn/route.c +3 -1
@@ -342,7 +342,9 @@ goto fail; } special.s_addr =htonl (special.s_addr); - ret =openvpn_getaddrinfo (0 ,inet_ntoa (special),NULL ,0 ,NULL , +char buf[INET_ADDRSTRLEN ]; +inet_ntop (AF_INET , &special, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (0 , buf,NULL ,0 ,NULL ,AF_INET , network_list); }else
src/openvpn/socket.c +11 -13
@@ -2901,16 +2901,16 @@ print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc) { struct in_addr ia; -struct buffer out =alloc_buf_gc (64 , gc); +char *out =gc_malloc (INET_ADDRSTRLEN , true, gc);if (addr || !(flags &IA_EMPTY_IF_UNDEF )) {CLEAR (ia); ia.s_addr = (flags &IA_NET_ORDER ) ? addr :htonl (addr); -buf_printf (&out,"%s" ,inet_ntoa (ia)); +inet_ntop (AF_INET , &ia, out,INET_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2920,16 +2920,14 @@const char *print_in6_addr (struct in6_addr a6,unsigned int flags,struct gc_arena *gc) { -struct buffer out =alloc_buf_gc (64 , gc); -char tmp_out_buf[64 ];/* inet_ntop wants pointer to buffer */ +char *out =gc_malloc (INET6_ADDRSTRLEN , true, gc);if (memcmp (&a6, &in6addr_any,sizeof (a6)) !=0 || !(flags &IA_EMPTY_IF_UNDEF )) { -inet_ntop (AF_INET6 , &a6, tmp_out_buf,sizeof (tmp_out_buf)-1 ); -buf_printf (&out,"%s" , tmp_out_buf ); +inet_ntop (AF_INET6 , &a6, out,INET6_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2978,7 +2976,7 @@ {char name_buf[256 ]; -char buf[128 ]; +char buf[INET6_ADDRSTRLEN ];switch (addr->addr.sa.sa_family) {case AF_INET :
@@ -2991,7 +2989,8 @@openvpn_snprintf (name_buf,sizeof (name_buf),"%s" , name_prefix); } -setenv_str (es, name_buf,inet_ntoa (addr->addr.in4.sin_addr)); +inet_ntop (AF_INET , &addr->addr.in4.sin_addr, buf,sizeof (buf)); +setenv_str (es, name_buf, buf);if ((flags &SA_IP_PORT ) && addr->addr.in4.sin_port) {
@@ -3007,13 +3006,12 @@memcpy (&ia.s_addr, &addr->addr.in6.sin6_addr.s6_addr[12 ],sizeof (ia.s_addr));openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip" , name_prefix); -openvpn_snprintf (buf,sizeof (buf),"%s" ,inet_ntoa (ia) ); +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); }else {openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip6" , name_prefix); -getnameinfo (&addr->addr.sa,sizeof (struct sockaddr_in6 ), - buf,sizeof (buf),NULL ,0 ,NI_NUMERICHOST ); +inet_ntop (AF_INET6 , &addr->addr.in6.sin6_addr, buf,sizeof (buf)); }setenv_str (es, name_buf, buf);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/326?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I052bebe720ddf26340827f25b94705945e470bfa
Gerrit-Change-Number: 326
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email )
Change subject: Remove last uses of inet_ntoa
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/326?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I052bebe720ddf26340827f25b94705945e470bfa
Gerrit-Change-Number: 326
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sun, 08 Oct 2023 09:18:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH 1/1 Remove last uses of inet_ntoa
In reply to a message not in the archiveinet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/326
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/manage.c +3 -1
@@ -3058,9 +3058,11 @@/* listen on our local TUN/TAP IP address */ struct in_addr ia;int ret; +char buf[INET_ADDRSTRLEN ]; ia.s_addr =htonl (tun_local_ip); - ret =openvpn_getaddrinfo (GETADDR_PASSIVE ,inet_ntoa (ia),NULL ,0 ,NULL , +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (GETADDR_PASSIVE , buf,NULL ,0 ,NULL ,AF_INET , &man->settings.local);ASSERT (ret==0 );man_connection_init (man);
src/openvpn/route.c +3 -1
@@ -342,7 +342,9 @@ goto fail; } special.s_addr =htonl (special.s_addr); - ret =openvpn_getaddrinfo (0 ,inet_ntoa (special),NULL ,0 ,NULL , +char buf[INET_ADDRSTRLEN ]; +inet_ntop (AF_INET , &special, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (0 , buf,NULL ,0 ,NULL ,AF_INET , network_list); }else
src/openvpn/socket.c +11 -13
@@ -2901,16 +2901,16 @@ print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc) { struct in_addr ia; -struct buffer out =alloc_buf_gc (64 , gc); +char *out =gc_malloc (INET_ADDRSTRLEN , true, gc);if (addr || !(flags &IA_EMPTY_IF_UNDEF )) {CLEAR (ia); ia.s_addr = (flags &IA_NET_ORDER ) ? addr :htonl (addr); -buf_printf (&out,"%s" ,inet_ntoa (ia)); +inet_ntop (AF_INET , &ia, out,INET_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2920,16 +2920,14 @@const char *print_in6_addr (struct in6_addr a6,unsigned int flags,struct gc_arena *gc) { -struct buffer out =alloc_buf_gc (64 , gc); -char tmp_out_buf[64 ];/* inet_ntop wants pointer to buffer */ +char *out =gc_malloc (INET6_ADDRSTRLEN , true, gc);if (memcmp (&a6, &in6addr_any,sizeof (a6)) !=0 || !(flags &IA_EMPTY_IF_UNDEF )) { -inet_ntop (AF_INET6 , &a6, tmp_out_buf,sizeof (tmp_out_buf)-1 ); -buf_printf (&out,"%s" , tmp_out_buf ); +inet_ntop (AF_INET6 , &a6, out,INET6_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2978,7 +2976,7 @@ {char name_buf[256 ]; -char buf[128 ]; +char buf[INET6_ADDRSTRLEN ];switch (addr->addr.sa.sa_family) {case AF_INET :
@@ -2991,7 +2989,8 @@openvpn_snprintf (name_buf,sizeof (name_buf),"%s" , name_prefix); } -setenv_str (es, name_buf,inet_ntoa (addr->addr.in4.sin_addr)); +inet_ntop (AF_INET , &addr->addr.in4.sin_addr, buf,sizeof (buf)); +setenv_str (es, name_buf, buf);if ((flags &SA_IP_PORT ) && addr->addr.in4.sin_port) {
@@ -3007,13 +3006,12 @@memcpy (&ia.s_addr, &addr->addr.in6.sin6_addr.s6_addr[12 ],sizeof (ia.s_addr));openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip" , name_prefix); -openvpn_snprintf (buf,sizeof (buf),"%s" ,inet_ntoa (ia) ); +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); }else {openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip6" , name_prefix); -getnameinfo (&addr->addr.sa,sizeof (struct sockaddr_in6 ), - buf,sizeof (buf),NULL ,0 ,NI_NUMERICHOST ); +inet_ntop (AF_INET6 , &addr->addr.in6.sin6_addr, buf,sizeof (buf)); }setenv_str (es, name_buf, buf);
[Openvpn-devel] [PATCH applied] Re: Remove last uses of inet_ntoa
I wouldn't claim to understand what management_post_tunnel_open() or init_route() *does* here (why is it converting a numeric address back to ascii, just to feed it to getaddrinfo() afterwards?), but the actual code changes look reasonable.
Same for the "buffer" to "char *" changes, especially in print_in6_addr().
As this is "refactoring to appease compilers", and neither a bugfix nor "real" compat stuff, it only goes to master.
Your patch has been applied to the master branch.
commit 7c637b35038e4cc7d2f16e07f413cfa2b0f1f97a
Author: Frank Lichtenheld Date: Sun Oct 8 12:34:15 2023 +0200
Remove last uses of inet_ntoa
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: Remove last uses of inet_ntoa
......................................................................
Remove last uses of inet_ntoa
inet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
---
M src/openvpn/manage.c
M src/openvpn/route.c
M src/openvpn/socket.c
3 files changed, 17 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/326/2
src/openvpn/manage.c +3 -1
@@ -3058,9 +3058,11 @@/* listen on our local TUN/TAP IP address */ struct in_addr ia;int ret; +char buf[INET_ADDRSTRLEN ]; ia.s_addr =htonl (tun_local_ip); - ret =openvpn_getaddrinfo (GETADDR_PASSIVE ,inet_ntoa (ia),NULL ,0 ,NULL , +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (GETADDR_PASSIVE , buf,NULL ,0 ,NULL ,AF_INET , &man->settings.local);ASSERT (ret==0 );man_connection_init (man);
src/openvpn/route.c +3 -1
@@ -342,7 +342,9 @@ goto fail; } special.s_addr =htonl (special.s_addr); - ret =openvpn_getaddrinfo (0 ,inet_ntoa (special),NULL ,0 ,NULL , +char buf[INET_ADDRSTRLEN ]; +inet_ntop (AF_INET , &special, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (0 , buf,NULL ,0 ,NULL ,AF_INET , network_list); }else
src/openvpn/socket.c +11 -13
@@ -2901,16 +2901,16 @@ print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc) { struct in_addr ia; -struct buffer out =alloc_buf_gc (64 , gc); +char *out =gc_malloc (INET_ADDRSTRLEN , true, gc);if (addr || !(flags &IA_EMPTY_IF_UNDEF )) {CLEAR (ia); ia.s_addr = (flags &IA_NET_ORDER ) ? addr :htonl (addr); -buf_printf (&out,"%s" ,inet_ntoa (ia)); +inet_ntop (AF_INET , &ia, out,INET_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2920,16 +2920,14 @@const char *print_in6_addr (struct in6_addr a6,unsigned int flags,struct gc_arena *gc) { -struct buffer out =alloc_buf_gc (64 , gc); -char tmp_out_buf[64 ];/* inet_ntop wants pointer to buffer */ +char *out =gc_malloc (INET6_ADDRSTRLEN , true, gc);if (memcmp (&a6, &in6addr_any,sizeof (a6)) !=0 || !(flags &IA_EMPTY_IF_UNDEF )) { -inet_ntop (AF_INET6 , &a6, tmp_out_buf,sizeof (tmp_out_buf)-1 ); -buf_printf (&out,"%s" , tmp_out_buf ); +inet_ntop (AF_INET6 , &a6, out,INET6_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2978,7 +2976,7 @@ {char name_buf[256 ]; -char buf[128 ]; +char buf[INET6_ADDRSTRLEN ];switch (addr->addr.sa.sa_family) {case AF_INET :
@@ -2991,7 +2989,8 @@openvpn_snprintf (name_buf,sizeof (name_buf),"%s" , name_prefix); } -setenv_str (es, name_buf,inet_ntoa (addr->addr.in4.sin_addr)); +inet_ntop (AF_INET , &addr->addr.in4.sin_addr, buf,sizeof (buf)); +setenv_str (es, name_buf, buf);if ((flags &SA_IP_PORT ) && addr->addr.in4.sin_port) {
@@ -3007,13 +3006,12 @@memcpy (&ia.s_addr, &addr->addr.in6.sin6_addr.s6_addr[12 ],sizeof (ia.s_addr));openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip" , name_prefix); -openvpn_snprintf (buf,sizeof (buf),"%s" ,inet_ntoa (ia) ); +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); }else {openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip6" , name_prefix); -getnameinfo (&addr->addr.sa,sizeof (struct sockaddr_in6 ), - buf,sizeof (buf),NULL ,0 ,NI_NUMERICHOST ); +inet_ntop (AF_INET6 , &addr->addr.in6.sin6_addr, buf,sizeof (buf)); }setenv_str (es, name_buf, buf);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/326?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I052bebe720ddf26340827f25b94705945e470bfa
Gerrit-Change-Number: 326
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email )
Change subject: Remove last uses of inet_ntoa
......................................................................
Remove last uses of inet_ntoa
inet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
---
M src/openvpn/manage.c
M src/openvpn/route.c
M src/openvpn/socket.c
3 files changed, 17 insertions(+), 15 deletions(-)
src/openvpn/manage.c +3 -1
@@ -3058,9 +3058,11 @@/* listen on our local TUN/TAP IP address */ struct in_addr ia;int ret; +char buf[INET_ADDRSTRLEN ]; ia.s_addr =htonl (tun_local_ip); - ret =openvpn_getaddrinfo (GETADDR_PASSIVE ,inet_ntoa (ia),NULL ,0 ,NULL , +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (GETADDR_PASSIVE , buf,NULL ,0 ,NULL ,AF_INET , &man->settings.local);ASSERT (ret==0 );man_connection_init (man);
src/openvpn/route.c +3 -1
@@ -342,7 +342,9 @@ goto fail; } special.s_addr =htonl (special.s_addr); - ret =openvpn_getaddrinfo (0 ,inet_ntoa (special),NULL ,0 ,NULL , +char buf[INET_ADDRSTRLEN ]; +inet_ntop (AF_INET , &special, buf,sizeof (buf)); + ret =openvpn_getaddrinfo (0 , buf,NULL ,0 ,NULL ,AF_INET , network_list); }else
src/openvpn/socket.c +11 -13
@@ -2901,16 +2901,16 @@ print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc) { struct in_addr ia; -struct buffer out =alloc_buf_gc (64 , gc); +char *out =gc_malloc (INET_ADDRSTRLEN , true, gc);if (addr || !(flags &IA_EMPTY_IF_UNDEF )) {CLEAR (ia); ia.s_addr = (flags &IA_NET_ORDER ) ? addr :htonl (addr); -buf_printf (&out,"%s" ,inet_ntoa (ia)); +inet_ntop (AF_INET , &ia, out,INET_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2920,16 +2920,14 @@const char *print_in6_addr (struct in6_addr a6,unsigned int flags,struct gc_arena *gc) { -struct buffer out =alloc_buf_gc (64 , gc); -char tmp_out_buf[64 ];/* inet_ntop wants pointer to buffer */ +char *out =gc_malloc (INET6_ADDRSTRLEN , true, gc);if (memcmp (&a6, &in6addr_any,sizeof (a6)) !=0 || !(flags &IA_EMPTY_IF_UNDEF )) { -inet_ntop (AF_INET6 , &a6, tmp_out_buf,sizeof (tmp_out_buf)-1 ); -buf_printf (&out,"%s" , tmp_out_buf ); +inet_ntop (AF_INET6 , &a6, out,INET6_ADDRSTRLEN ); } -return BSTR (&out); +return out; }/*
@@ -2978,7 +2976,7 @@ {char name_buf[256 ]; -char buf[128 ]; +char buf[INET6_ADDRSTRLEN ];switch (addr->addr.sa.sa_family) {case AF_INET :
@@ -2991,7 +2989,8 @@openvpn_snprintf (name_buf,sizeof (name_buf),"%s" , name_prefix); } -setenv_str (es, name_buf,inet_ntoa (addr->addr.in4.sin_addr)); +inet_ntop (AF_INET , &addr->addr.in4.sin_addr, buf,sizeof (buf)); +setenv_str (es, name_buf, buf);if ((flags &SA_IP_PORT ) && addr->addr.in4.sin_port) {
@@ -3007,13 +3006,12 @@memcpy (&ia.s_addr, &addr->addr.in6.sin6_addr.s6_addr[12 ],sizeof (ia.s_addr));openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip" , name_prefix); -openvpn_snprintf (buf,sizeof (buf),"%s" ,inet_ntoa (ia) ); +inet_ntop (AF_INET , &ia, buf,sizeof (buf)); }else {openvpn_snprintf (name_buf,sizeof (name_buf),"%s_ip6" , name_prefix); -getnameinfo (&addr->addr.sa,sizeof (struct sockaddr_in6 ), - buf,sizeof (buf),NULL ,0 ,NI_NUMERICHOST ); +inet_ntop (AF_INET6 , &addr->addr.in6.sin6_addr, buf,sizeof (buf)); }setenv_str (es, name_buf, buf);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/326?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I052bebe720ddf26340827f25b94705945e470bfa
Gerrit-Change-Number: 326
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged